home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
651-660
/
656
/
jbspool
/
source
/
jbspoolgadgets.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-15
|
11KB
|
359 lines
/*
* Source generated with GadToolsBox V1.3
* which is (c) Copyright 1991,92 Jaba Development
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <string.h>
#include "JbSpoolGadgets.h"
struct Screen *Scr = NULL;
APTR VisualInfo = NULL;
struct Window *SpoolWnd = NULL;
struct Gadget *SpoolGList = NULL;
struct Menu *SpoolMenus = NULL;
UWORD SpoolZoom[4];
struct Gadget *SpoolGadgets[17];
UWORD SpoolLeft = 69;
UWORD SpoolTop = 32;
UWORD SpoolWidth = 472;
UWORD SpoolHeight = 106;
UBYTE *SpoolWdt = NULL;
extern struct GfxBase *GfxBase;
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
struct NewMenu SpoolNewMenu[] = {
NM_TITLE, (STRPTR)"Project", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"About...", (STRPTR)"?", 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Add...", (STRPTR)"A", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Remove...", (STRPTR)"R", 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Hide", (STRPTR)"H", 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Quit", (STRPTR)"Q", 0, 0L, NULL,
NM_TITLE, (STRPTR)"Control", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Up", (STRPTR)"U", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Down", (STRPTR)"D", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top", (STRPTR)"T", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom", (STRPTR)"B", 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Stop", (STRPTR)"S", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Continue", (STRPTR)"C", 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Abort", (STRPTR)"O", 0, 0L, NULL,
NM_END, NULL, NULL, 0, 0L, NULL };
static UWORD ComputeX( UWORD value )
{
return(( UWORD )(( FontX * value ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )(( FontY * value ) / 8 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Font = &Attr;
Font->ta_Name = GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
FontX = GfxBase->DefaultFont->tf_XSize;
OffY = Scr->Font->ta_YSize + Scr->WBorTop + 1;
OffX = Scr->WBorLeft;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( NULL )))
return( 1L );
ComputeFont( 0L, 0L );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
UnlockPubScreen( NULL, Scr );
Scr = NULL;
}
}
int OpenSpoolWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD wleft = SpoolLeft, wtop = SpoolTop, ww, wh;
ComputeFont( SpoolWidth, SpoolHeight );
ww = ComputeX( SpoolWidth );
wh = ComputeY( SpoolHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &SpoolGList )))
return( 1L );
ng.ng_LeftEdge = OffX + ComputeX( 7 );
ng.ng_TopEdge = OffY + ComputeY( 4 );
ng.ng_Width = ComputeX( 178 );
ng.ng_Height = ComputeY( 64 );
ng.ng_GadgetText = NULL;
ng.ng_TextAttr = Font;
ng.ng_GadgetID = GD_QUEUE;
ng.ng_Flags = 0;
ng.ng_VisualInfo = VisualInfo;
g = CreateGadget( LISTVIEW_KIND, g, &ng, GTLV_Labels, NULL, GTLV_ShowSelected, NULL, TAG_DONE );
SpoolGadgets[ 0 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 286 );
ng.ng_Height = ComputeY( 13 );
ng.ng_GadgetText = (UBYTE *)"Printing :";
ng.ng_GadgetID = GD_CURRENT;
ng.ng_Flags = PLACETEXT_LEFT;
g = CreateGadget( TEXT_KIND, g, &ng, GTTX_Border, TRUE, TAG_DONE );
SpoolGadgets[ 1 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 7 );
ng.ng_TopEdge = OffY + ComputeY( 71 );
ng.ng_Width = ComputeX( 85 );
ng.ng_Height = ComputeY( 14 );
ng.ng_GadgetText = (UBYTE *)"Add...";
ng.ng_GadgetID = GD_ADD;
ng.ng_Flags = PLACETEXT_IN;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 2 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 100 );
ng.ng_GadgetText = (UBYTE *)"Remove...";
ng.ng_GadgetID = GD_REMOVE;
ng.ng_Flags = 0;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 3 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 286 );
ng.ng_GadgetText = (UBYTE *)"Down";
ng.ng_GadgetID = GD_DOWN;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 4 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 7 );
ng.ng_TopEdge = OffY + ComputeY( 89 );
ng.ng_GadgetText = (UBYTE *)"Bottom";
ng.ng_GadgetID = GD_BOTTOM;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 5 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 100 );
ng.ng_GadgetText = (UBYTE *)"Stop";
ng.ng_GadgetID = GD_STOP;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 6 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 379 );
ng.ng_TopEdge = OffY + ComputeY( 71 );
ng.ng_GadgetText = (UBYTE *)"Top";
ng.ng_GadgetID = GD_TOP;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 7 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 193 );
ng.ng_TopEdge = OffY + ComputeY( 89 );
ng.ng_GadgetText = (UBYTE *)"Continue";
ng.ng_GadgetID = GD_CONT;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 8 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 286 );
ng.ng_GadgetText = (UBYTE *)"Hide";
ng.ng_GadgetID = GD_HIDE;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 9 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 379 );
ng.ng_GadgetText = (UBYTE *)"Quit";
ng.ng_GadgetID = GD_QUIT;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 10 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 193 );
ng.ng_TopEdge = OffY + ComputeY( 71 );
ng.ng_GadgetText = (UBYTE *)"Up";
ng.ng_GadgetID = GD_UP;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 11 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 379 );
ng.ng_TopEdge = OffY + ComputeY( 20 );
ng.ng_GadgetText = (UBYTE *)"Abort";
ng.ng_GadgetID = GD_ABORT;
g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 12 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 286 );
ng.ng_TopEdge = OffY + ComputeY( 21 );
ng.ng_GadgetText = (UBYTE *)"Insert FF :";
ng.ng_GadgetID = GD_FF;
g = CreateGadget( CHECKBOX_KIND, g, &ng, TAG_DONE );
SpoolGadgets[ 13 ] = g;
ng.ng_TopEdge = OffY + ComputeY( 37 );
ng.ng_Width = ComputeX( 178 );
ng.ng_Height = ComputeY( 14 );
ng.ng_GadgetText = (UBYTE *)"Minutes :";
ng.ng_GadgetID = GD_MINS;
ng.ng_Flags = PLACETEXT_LEFT;
g = CreateGadget( INTEGER_KIND, g, &ng, GTIN_Number, 0, GTIN_MaxChars, 3, TAG_DONE );
SpoolGadgets[ 14 ] = g;
ng.ng_TopEdge = OffY + ComputeY( 54 );
ng.ng_GadgetText = (UBYTE *)"Seconds :";
ng.ng_GadgetID = GD_SECS;
ng.ng_Flags = 0;
g = CreateGadget( INTEGER_KIND, g, &ng, GTIN_Number, 0, GTIN_MaxChars, 10, TAG_DONE );
SpoolGadgets[ 15 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 338 );
ng.ng_TopEdge = OffY + ComputeY( 20 );
ng.ng_Width = ComputeX( 33 );
ng.ng_GadgetText = (UBYTE *)"%";
ng.ng_GadgetID = GD_DONE;
ng.ng_Flags = PLACETEXT_LEFT;
g = CreateGadget( NUMBER_KIND, g, &ng, GTNM_Border, TRUE, TAG_DONE );
SpoolGadgets[ 16 ] = g;
if ( ! g )
return( 2L );
if ( ! ( SpoolMenus = CreateMenus( SpoolNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
return( 3L );
LayoutMenus( SpoolMenus, VisualInfo, TAG_DONE );
if ( SpoolWdt )
SpoolZoom[2] = TextLength( &Scr->RastPort, (UBYTE *)SpoolWdt, strlen((char *)SpoolWdt )) + 80;
else
SpoolZoom[2] = 80L;
SpoolZoom[0] = SpoolZoom[1] = 0;
SpoolZoom[3] = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
if ( ! ( SpoolWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, LISTVIEWIDCMP|TEXTIDCMP|BUTTONIDCMP|CHECKBOXIDCMP|INTEGERIDCMP|NUMBERIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_CHANGEWINDOW|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, SpoolGList,
WA_Title, SpoolWdt,
WA_ScreenTitle, "JbSpool, © Copyright 1992 Jaba Development",
WA_PubScreen, Scr,
WA_Zoom, SpoolZoom,
TAG_DONE )))
return( 4L );
SpoolZoom[0] = SpoolWnd->LeftEdge;
SpoolZoom[1] = SpoolWnd->TopEdge;
SpoolZoom[2] = SpoolWnd->Width;
SpoolZoom[3] = SpoolWnd->Height;
SetMenuStrip( SpoolWnd, SpoolMenus );
GT_RefreshWindow( SpoolWnd, NULL );
return( 0L );
}
void CloseSpoolWindow( void )
{
if ( SpoolMenus ) {
ClearMenuStrip( SpoolWnd );
FreeMenus( SpoolMenus );
SpoolMenus = NULL; }
if ( SpoolWnd ) {
CloseWindow( SpoolWnd );
SpoolWnd = NULL;
}
if ( SpoolGList ) {
FreeGadgets( SpoolGList );
SpoolGList = NULL;
}
}